<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="​        原文地址：https:&#x2F;&#x2F;blog.csdn.net&#x2F;WCH_TechGroup&#x2F;article&#x2F;details&#x2F;124803364 ​        PCIe转串口芯片CH382&#x2F;CH384以及PCI转串口芯片CH351&#x2F;CH352&#x2F;CH353&#x2F;CH355&#x2F;CH356&#x2F;CH357&#x2F;CH358&#x2F;CH359以及使用如上芯片外加CH432&#x2F;CH438的组合串口转接方案均支持Windo">
<meta property="og:type" content="article">
<meta property="og:title" content="PCIe转串口Linux驱动使用说明">
<meta property="og:url" content="http://example.com/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="​        原文地址：https:&#x2F;&#x2F;blog.csdn.net&#x2F;WCH_TechGroup&#x2F;article&#x2F;details&#x2F;124803364 ​        PCIe转串口芯片CH382&#x2F;CH384以及PCI转串口芯片CH351&#x2F;CH352&#x2F;CH353&#x2F;CH355&#x2F;CH356&#x2F;CH357&#x2F;CH358&#x2F;CH359以及使用如上芯片外加CH432&#x2F;CH438的组合串口转接方案均支持Windo">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-04-14T12:58:10.000Z">
<meta property="article:modified_time" content="2023-04-14T12:58:10.000Z">
<meta property="article:author" content="xudonglei">
<meta property="article:tag" content="Linux驱动">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>PCIe转串口Linux驱动使用说明 | 学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          PCIe转串口Linux驱动使用说明
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-04-14 20:58:10" itemprop="dateCreated datePublished" datetime="2023-04-14T20:58:10+08:00">2023-04-14</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
                </span>
            </span>

          
            <span id="/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/" class="post-meta-item leancloud_visitors" data-flag-title="PCIe转串口Linux驱动使用说明" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>​        原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/WCH_TechGroup/article/details/124803364">https://blog.csdn.net/WCH_TechGroup/article/details/124803364</a></p>
<p>​        PCIe转串口芯片CH382/CH384以及PCI转串口芯片CH351/CH352/CH353/CH355/CH356/CH357/CH358/CH359以及使用如上芯片外加CH432/CH438的组合串口转接方案均支持Windows和Linux操作系统，在系统下会生成多个独立的串口，各虚拟串口分别对应一个硬件串口。各串口独立工作，互不影响。本文主要介绍Linux操作系统如何为设备加载厂商串口驱动。</p>
<p>​        厂商驱动下载链接： <a target="_blank" rel="noopener" href="http://www.wch.cn/downloads/CH38XDRV_ZIP.html">http://www.wch.cn/downloads/CH38XDRV_ZIP.html</a></p>
<p>​        厂商驱动Github链接：<a target="_blank" rel="noopener" href="https://github.com/WCHSoftGroup/ch35_38x_linux">https://github.com/WCHSoftGroup/ch35_38x_linux</a></p>
<h3 id="步骤一：解绑系统内置串口驱动"><a href="#步骤一：解绑系统内置串口驱动" class="headerlink" title="步骤一：解绑系统内置串口驱动"></a>步骤一：解绑系统内置串口驱动</h3><h4 id="确定串口卡状态"><a href="#确定串口卡状态" class="headerlink" title="确定串口卡状态"></a>确定串口卡状态</h4><p>​        Linux内核中，系统启动时会自动加载内置的8250_pci驱动。该驱动包含各厂家PCI/PCIe产品，可以通过lspci命令确认当前硬件的工作状态以及驱动匹配情况。CH35x和CH38x芯片使用的VID有2种：0x1C00和0x4348，命令为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">lspci -vd 1c00:*</span><br><span class="line">lspci -vd 13a8:*</span><br></pre></td></tr></table></figure>
<p>​        运行如上命令后，若设备存在，则会显示如下设备信息：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">07:00.0 Serial controller: Device 1c00:3470 (rev 10) (prog-if 05 [16850])</span><br><span class="line">Subsystem: Device 1c00:3470</span><br><span class="line">Flags: fast devsel, IRQ 41</span><br><span class="line">I/O ports at 1000 [size=256]</span><br><span class="line">Memory at 58700000 (32-bit, prefetchable) [size=32K]</span><br><span class="line">I/O ports at 1100 [size=4]</span><br><span class="line">Expansion ROM at 58700000 [size=32K]</span><br><span class="line">Capabilities: [60] Power Management version 3</span><br><span class="line">Capabilities: [68] MSI: Enable- Count=1/32 Maskable+ 64bit+</span><br><span class="line">Capabilities: [80] Express Legacy Endpoint, MSI 00</span><br><span class="line">Capabilities: [100] Advanced Error Reporting</span><br><span class="line">Kernel driver in use: serial</span><br><span class="line">Kernel modules: 8250_pci</span><br></pre></td></tr></table></figure>
<p>​        如上所示，在“Kernel modules”信息中会显示当前已经为该设备加载的驱动。注：系统内置的可以满足设备基础串口通信的需求，该驱动为串口卡创建的设备名称为：/dev/ttySn，也可以通过dmesg | grep ttyS 通过对比ttyS的IO地址和lspci的地址来确定具体的ttyS通道。</p>
<p>​        如果需要使用扩展功能，如：支持串口高波特率通讯，开启半双工功能支持RS485串口通讯等，则务必使用厂商单独提供的串口驱动。</p>
<h4 id="解绑本地8250-pci串口驱动"><a href="#解绑本地8250-pci串口驱动" class="headerlink" title="解绑本地8250_pci串口驱动"></a>解绑本地8250_pci串口驱动</h4><p>​        执行如下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ls /sys/bus/pci/drivers/serial</span><br></pre></td></tr></table></figure>
<p>​        如上命令返回内容如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">0000:07:00.0 bind new_id remove_id uevent unbind</span><br></pre></td></tr></table></figure>
<p>​        使用如下命令完成驱动和设备的解绑：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">echo -n “0000:07:00.0” &gt; /sys/bus/pci/drivers/serial/unbind</span><br></pre></td></tr></table></figure>
<h3 id="步骤二：加载厂商串口驱动"><a href="#步骤二：加载厂商串口驱动" class="headerlink" title="步骤二：加载厂商串口驱动"></a>步骤二：加载厂商串口驱动</h3><p>1、从开头的链接地址下载驱动到本地，也可以通过git clone。</p>
<p>2、参考驱动文件夹中的README.md文档完成驱动的编译和移植工作。</p>
<p>3、设备存在且工作正常的情况下，驱动会为设备生成名称为“/dev/ttyWCH”开头的串口节点。</p>
<p>若驱动加载时出错，可能原因有：</p>
<p>1、系统当前未发现任何CH35x和CH38x串口卡。</p>
<p>2、系统默认为CH35x和CH38x串口卡分配的IO地址不可用，导致驱动无法成功访问硬件，甚至造成系统Crash。原因：CH35x和CH38x串口卡的相关串口寄存器均位于IO空间内，部分非X86和X64的架构不支持独立编址或者支持分配地址但地址无法通过原生IO地址操作直接访问，此时可联系相应CPU或系统厂商咨询解决方法。</p>
<p>3、若使用CH35x和CH38x与CH43x的组合芯片方案，当主芯片和CH43x的硬件通讯异常，驱动加载也会报错，此时可以更换其他系统平台进行验证以排除原因2的问题。若其他系统上如Windows可以正常工作，则硬件正常，仅检查原因2即可。</p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Linux%E9%A9%B1%E5%8A%A8/" rel="tag"># Linux驱动</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2023/04/02/%E6%A0%91%E8%8E%93%E6%B4%BECM4%20eMMC%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99/" rel="prev" title="树莓派CM4 eMMC系统烧写">
      <i class="fa fa-chevron-left"></i> 树莓派CM4 eMMC系统烧写
    </a></div>
      <div class="post-nav-item">
    <a href="/2023/04/15/Verilog%E7%9A%84inout%E8%AF%AD%E5%8F%A5/" rel="next" title="Verilog的inout语句">
      Verilog的inout语句 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%AD%A5%E9%AA%A4%E4%B8%80%EF%BC%9A%E8%A7%A3%E7%BB%91%E7%B3%BB%E7%BB%9F%E5%86%85%E7%BD%AE%E4%B8%B2%E5%8F%A3%E9%A9%B1%E5%8A%A8"><span class="nav-number">1.</span> <span class="nav-text">步骤一：解绑系统内置串口驱动</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E7%A1%AE%E5%AE%9A%E4%B8%B2%E5%8F%A3%E5%8D%A1%E7%8A%B6%E6%80%81"><span class="nav-number">1.1.</span> <span class="nav-text">确定串口卡状态</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%A7%A3%E7%BB%91%E6%9C%AC%E5%9C%B08250-pci%E4%B8%B2%E5%8F%A3%E9%A9%B1%E5%8A%A8"><span class="nav-number">1.2.</span> <span class="nav-text">解绑本地8250_pci串口驱动</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%AD%A5%E9%AA%A4%E4%BA%8C%EF%BC%9A%E5%8A%A0%E8%BD%BD%E5%8E%82%E5%95%86%E4%B8%B2%E5%8F%A3%E9%A9%B1%E5%8A%A8"><span class="nav-number">2.</span> <span class="nav-text">步骤二：加载厂商串口驱动</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
